package com.jwsoft.manager.core.dao.service.impl;

import com.bifang.module.base.common.util.CommonSecureUtil;
import com.jwsoft.manager.core.dao.model.EduhHouse;
import com.jwsoft.manager.core.dao.mapper.EduhHouseMapper;
import com.jwsoft.manager.core.dao.service.EduhHouseService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;

/**
 * 房产信息历史表服务实现类
 *
 * @author zhiyuan
 * @since 2023-09-20
 */
@Service
public class EduhHouseServiceImpl extends ServiceImpl<EduhHouseMapper, EduhHouse> implements EduhHouseService {

    @Override
    public void decrypt(EduhHouse eduhHouse) {
        if (StringUtils.isNotBlank(eduhHouse.getAddress())) {
            eduhHouse.setAddress(CommonSecureUtil.sm4Decrypt(eduhHouse.getAddress()));
        }
        if (StringUtils.isNotBlank(eduhHouse.getQlrName())) {
            eduhHouse.setQlrName(CommonSecureUtil.sm4Decrypt(eduhHouse.getQlrName()));
        }
    }

    @Override
    public void encrypt(EduhHouse eduhHouse) {
        if (StringUtils.isNotBlank(eduhHouse.getAddress())) {
            eduhHouse.setAddress(CommonSecureUtil.sm4Encrypt(eduhHouse.getAddress()));
        }
        if (StringUtils.isNotBlank(eduhHouse.getQlrName())) {
            eduhHouse.setQlrName(CommonSecureUtil.sm4Encrypt(eduhHouse.getQlrName()));
        }
    }
}
